# 自动复制参考网站资源到当前项目
# 使用方法: powershell -ExecutionPolicy Bypass -File copy-assets.ps1

$source = "E:\utils\xft\Website\Zz_aftech.by\static"
$dest = "src\assets"

Write-Host "开始复制资源文件..." -ForegroundColor Green

# 创建目录结构
Write-Host "创建目录结构..." -ForegroundColor Yellow
$directories = @(
    "$dest\images\partners",
    "$dest\images\clients",
    "$dest\images\services",
    "$dest\images\contacts",
    "$dest\images\backgrounds",
    "$dest\images\icons",
    "$dest\fonts"
)

foreach ($dir in $directories) {
    if (-not (Test-Path $dir)) {
        New-Item -ItemType Directory -Force -Path $dir | Out-Null
        Write-Host "  ✓ 创建目录: $dir" -ForegroundColor Gray
    }
}

# 函数：复制文件并显示进度
function Copy-WithProgress {
    param($source, $dest, $description)
    
    if (Test-Path $source) {
        Copy-Item $source $dest -Force -ErrorAction SilentlyContinue
        Write-Host "  ✓ $description" -ForegroundColor Green
        return $true
    } else {
        Write-Host "  ✗ 未找到: $description" -ForegroundColor Red
        return $false
    }
}

# 1. 复制Logo和主要图标
Write-Host "`n复制Logo和图标..." -ForegroundColor Yellow
Copy-WithProgress "$source\picture\logo.svg" "$dest\images\" "Logo (SVG)"
Copy-WithProgress "$source\picture\no_text_logo.svg" "$dest\images\" "无文字Logo"
Copy-WithProgress "$source\picture\circle_shape.svg" "$dest\images\" "圆形边框"
Copy-WithProgress "$source\picture\arrow_right.svg" "$dest\images\" "右箭头"

# 2. 复制关于我们图标
Write-Host "`n复制关于我们图标..." -ForegroundColor Yellow
for ($i = 1; $i -le 6; $i++) {
    Copy-WithProgress "$source\picture\about$i.svg" "$dest\images\icons\" "关于图标 $i"
}

# 3. 复制联系图标
Write-Host "`n复制联系图标..." -ForegroundColor Yellow
$contactIcons = @("phone", "mail", "pin", "document")
foreach ($icon in $contactIcons) {
    Copy-WithProgress "$source\picture\$icon.svg" "$dest\images\icons\" "图标: $icon"
}

# 4. 复制背景图片
Write-Host "`n复制背景图片..." -ForegroundColor Yellow
$backgrounds = @("bg_head", "bg_about", "bg_partners", "bg_clients", "bg_contacts")
foreach ($bg in $backgrounds) {
    Copy-WithProgress "$source\image\$bg.jpg" "$dest\images\backgrounds\" "背景: $bg"
}
Copy-WithProgress "$source\image\3d_screen_bg_image.jpg" "$dest\images\backgrounds\" "3D背景"

# 5. 复制合作伙伴logo
Write-Host "`n复制合作伙伴Logo..." -ForegroundColor Yellow
for ($i = 1; $i -le 6; $i++) {
    Copy-WithProgress "$source\picture\p$i.png" "$dest\images\partners\" "合作伙伴 $i"
}
Copy-WithProgress "$source\picture\logo.jpg" "$dest\images\partners\" "合作伙伴Logo"

# 6. 复制客户logo
Write-Host "`n复制客户Logo..." -ForegroundColor Yellow
for ($i = 1; $i -le 19; $i++) {
    Copy-WithProgress "$source\picture\c$i.png" "$dest\images\clients\" "客户 $i"
}
Copy-WithProgress "$source\picture\logo-2.png" "$dest\images\clients\" "客户Logo-2"

# 7. 复制服务图片
Write-Host "`n复制服务图片..." -ForegroundColor Yellow
for ($i = 1; $i -le 4; $i++) {
    Copy-WithProgress "$source\picture\s$i.jpg" "$dest\images\services\" "服务图片 $i"
}

# 8. 复制联系人照片
Write-Host "`n复制联系人照片..." -ForegroundColor Yellow
$contacts = @("Kozik", "Rayko", "Stetsko")
foreach ($contact in $contacts) {
    Copy-WithProgress "$source\picture\$contact.png" "$dest\images\contacts\" "联系人: $contact"
}

# 9. 复制字体文件
Write-Host "`n复制字体文件..." -ForegroundColor Yellow
$fonts = @("ProximaNova-Bold", "ProximaNova-Regular", "ProximaNova-Semibold")
foreach ($font in $fonts) {
    Copy-WithProgress "$source\font\$font.woff" "$dest\fonts\" "字体 WOFF: $font"
    Copy-WithProgress "$source\font\$font.ttf" "$dest\fonts\" "字体 TTF: $font"
    Copy-WithProgress "$source\font\$font.eot" "$dest\fonts\" "字体 EOT: $font"
}

# 10. 创建字体CSS文件
Write-Host "`n创建字体CSS文件..." -ForegroundColor Yellow

# 确保css目录存在
if (-not (Test-Path "$dest\css")) {
    New-Item -ItemType Directory -Force -Path "$dest\css" | Out-Null
}

$fontCss = @'
/* Proxima Nova 字体定义 */

@font-face {
  font-family: 'Proxima Nova';
  src: url('../fonts/ProximaNova-Regular.eot');
  src: url('../fonts/ProximaNova-Regular.eot?#iefix') format('embedded-opentype'),
       url('../fonts/ProximaNova-Regular.woff') format('woff'),
       url('../fonts/ProximaNova-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Proxima Nova';
  src: url('../fonts/ProximaNova-Semibold.eot');
  src: url('../fonts/ProximaNova-Semibold.eot?#iefix') format('embedded-opentype'),
       url('../fonts/ProximaNova-Semibold.woff') format('woff'),
       url('../fonts/ProximaNova-Semibold.ttf') format('truetype');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Proxima Nova';
  src: url('../fonts/ProximaNova-Bold.eot');
  src: url('../fonts/ProximaNova-Bold.eot?#iefix') format('embedded-opentype'),
       url('../fonts/ProximaNova-Bold.woff') format('woff'),
       url('../fonts/ProximaNova-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
'@

$fontCss | Out-File -FilePath "$dest\css\fonts.css" -Encoding UTF8
Write-Host "  ✓ 创建 fonts.css" -ForegroundColor Green

# 完成
Write-Host "`n================================================" -ForegroundColor Cyan
Write-Host "资源复制完成！" -ForegroundColor Green
Write-Host "================================================" -ForegroundColor Cyan
Write-Host "`n下一步：" -ForegroundColor Yellow
Write-Host "1. 在 src/main.ts 中添加: import './assets/css/fonts.css'" -ForegroundColor Gray
Write-Host "2. 运行 npm run dev 查看效果" -ForegroundColor Gray
Write-Host "3. 检查所有图片是否正确加载" -ForegroundColor Gray
Write-Host "`n提示：如果某些资源未找到，请手动从参考网站复制" -ForegroundColor Yellow

